U.S. Pat. No. 6,836,971 discloses a tilt-compensated electronic compass. Its operation is based on calculating, rather than on measuring, the earth's magnetic field component Z in a direction orthogonal to the two measurement axes of a 2-axis magnetic sensor. The orthogonal component Z can be calculated using a stored value for the earth's magnetic field strength applicable over a wide geographic region. The calculation also requires using measured field values from the 2-axis sensor. Once Z is known, and using input from a 2-axis tilt sensor, the compensated orthogonal components X and Y can be calculated by mathematically rotating the measured field strength values from a tilted 2-axis sensor back to the local horizontal plane.